# -*- coding: utf-8 -*-
from utils.session_mc import McVerifyStore

VERIFY_TYPE_FIND, VERIFY_TYPE_REGISTER = ['find', 'register']

def check_verify_code(phone, v_type, verify, del_code=False):
    verify_store = McVerifyStore()
    verify_list = verify_store.get(phone + v_type)
    if verify not in verify_list:
        return False
    else:
        if del_code:
            # use verify ,delete
            verify_list.remove(verify)
            verify_store.set(phone + v_type, verify_list)
        return True


def del_verify_code(phone, v_type, verify):
    # use verify ,delete
    verify_store = McVerifyStore()
    verify_list = verify_store.get(phone + v_type)
    if verify not in verify_list:
        return
    else:
        # use verify ,delete
        verify_list.remove(verify)
        verify_store.set(phone + v_type, verify_list)
        return

def save_verify_code(phone, v_type, verify):
    """
    TODO：最多存3条
    :param phone:
    :param verify:
    """
    verify_store = McVerifyStore()
    verify_store.add(phone + v_type, verify)
